using Blazored.LocalStorage;
using BlazorWebAssemblyDemo.Authentication;
using BlazorWebAssemblyDemo.Services;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SharedClassLibrary.Contracts;
using SharedClassLibrary.HttpRequest;

namespace BlazorWebAssemblyDemo
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("#app");
            builder.RootComponents.Add<HeadOutlet>("head::after");

            builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5029") });
            builder.Services.AddBlazoredLocalStorage();
            builder.Services.AddAuthorizationCore();
            builder.Services.AddScoped<AuthenticationStateProvider, JwtAuthenticationStateProvider>();
            builder.Services.AddScoped<IUserService, UserService>();
            builder.Services.AddApiClient(options => options.Address = "Http://localhost:5029");
            await builder.Build().RunAsync();
        }
    }
}
